using System;
using System.Windows.Forms;
using System.IO;

namespace PerformanceDude.MSBuildProfiler.Gui
{
    internal static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        private static int Main(string[] args)
        {
            try
            {
                if (args.Length > 0)
                {
                    if (!File.Exists(args[0]))
                    {
                        MessageBox.Show("Specified file does not exits: " + args[0]);
                        return -1;
                    }
                }
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(args.Length == 1 ? new MSBuildProfilerForm(args[0]) : new MSBuildProfilerForm());
            }
            catch (Exception e)
            {
                MessageBox.Show("Unknown exception occured. Closing.\n" + e.Message);
                return -100;
            }
            return 0;
        }
    }
}